package com.ruoyi.expertmodel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.expertmodel.domain.LoadModel;
import com.ruoyi.expertmodel.domain.PerformanceModel;
import com.ruoyi.expertmodel.mapper.LoadModelMapper;
import com.ruoyi.expertmodel.mapper.PerformanceModelMapper;
import com.ruoyi.expertmodel.service.LoadModelService;
import com.ruoyi.expertmodel.service.PerformanceModelService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PerformanceModelServiceImpl extends ServiceImpl<PerformanceModelMapper, PerformanceModel> implements PerformanceModelService {

    @Resource
    private PerformanceModelMapper PerformanceModelMapper;

    @Override
    public List<PerformanceModel> queryPerformanceModel(PerformanceModel PerformanceModel) {
        return PerformanceModelMapper.queryPerformanceModel(PerformanceModel);
    }

    @Override
    public boolean deletePerformanceModel(PerformanceModel PerformanceModel) {
        return PerformanceModelMapper.deletePerformanceModel(PerformanceModel.getId())>0;
    }

    @Override
    public boolean batchImport(List<PerformanceModel> PerformanceModels) {
        boolean flag = true;
        for(PerformanceModel e :PerformanceModels){
            try{
                boolean save = this.save(e);

                if(!save){
                    flag=false;
                }
            }catch (Exception e1){
                flag = false;

            }

        }
        return flag;
    }

    @Override
    public void copyPerformanceModel(PerformanceModel PerformanceModel) {
        //PerformanceModelMapper.insert(PerformanceModel);
        PerformanceModelMapper.insertOneObj(PerformanceModel);
    }


}
